#include "mainwindow.h"
#include "ui_mainwindow.h"

#include <QFileDialog>
#include <QFile>
#include <QDebug>
#include <QByteArray>

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);
}

MainWindow::~MainWindow()
{
    delete ui;
}


void MainWindow::on_pushButton_clicked()
{
    QString fileurl = QFileDialog::getOpenFileName(this, "选择你的文件", "/home/zhou", "*");
    if(fileurl.isEmpty())
    {
        qDebug() << "你没有选择文件";
        return;
    }
    QFile file(fileurl);
    if(file.open(QIODeviceBase::ReadWrite))
    {
        qDebug() << "打开文件成功";
    }
    else
    {
        qDebug() << "打开文件失败";
    }
    QByteArray ret =  file.readAll();
    QString str_ret(ret);
    qDebug() << str_ret;
    file.close();
}

